package com.safety51.bootstrap.demo.domain.example;

import com.safety51.bootstrap.commons.utils.BeanValidateUtils;
import com.safety51.bootstrap.demo.domain.student.entity.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liuyuancheng on 2021/9/3  <br/>
 *
 * @author liuyuancheng
 */
@Service
@Slf4j
public class BeanValidationExample {

    /**
     * 获取Bean验证结果（不抛出异常）
     * @return
     */
    public List<String> nameIsNull() {
        Student student = new Student();
        student.setId(1);
        student.setName(null);
        student.setEmail("asdfasdf123.com");
        student.setDateOfBirth("");
        return BeanValidateUtils.validateGetAllErrors(student);
    }

}
